package exit

import (
	"gitee.com/zaper/private-logger"
	"os"
	"os/signal"
	"syscall"
)

// GracefulExitMonitor 优雅退出
func GracefulExitMonitor() {
	quit := make(chan os.Signal, 1)
	signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
	var sign os.Signal
	select {
	case sign = <-quit:
		switch sign {
		case syscall.SIGINT:
			logger.Println("Sigint come in")
		case syscall.SIGTERM:
			logger.Println("Sigterm come in")
		default:
			logger.Printf("%f come in", sign)
		}
	}
	logger.Printf("System exit %s", sign.String())
}
